from database import db
from sqlalchemy import Column, String, Integer, func, DateTime, Numeric, ForeignKey
from .currency import Currency
from sqlalchemy.orm import relationship


class Account(db.Model):
    id = Column(String(100), primary_key=True)
    balance = Column(Numeric(precision=15, scale=4), doc='余额')
    frozen_amount = Column(Numeric(precision=15, scale=4), doc='冻结金额')
    pending_amount = Column(Numeric(precision=15, scale=4), doc='待结算金额')
    status = Column(String(10), default='normal')
    remark = Column(String(300), nullable=True)
    reward_amount = Column(Numeric(precision=15, scale=4), doc='奖励金额')
    updated_at = Column(DateTime(), default=func.now())
    created_at = Column(DateTime(), default=func.now())
    currency_id = Column(ForeignKey(Currency.id))
    currency = relationship(Currency)
